g08ahf
g08ahf
© Numerical Algorithms Group, 2002.
Purpose
G08AHF Performs the Mann-Whitney U test on two independent samples
Synopsis
[u,unor,p,ties,ranks,ifail] = g08ahf(x,y<,tail,ifail>)
Description
The Mann-Whitney U test investigates the difference between two
populations defined by the distribution functions F(x) and G(y)
respectively. The data consist of two independent samples of size
n and n , denoted by x ,x ,...,x and y ,y ,...,y , taken from
1 2 1 2 1 2
n n
1 2
the two populations.
The hypothesis under test, H , often called the null hypothesis,
0
is that the two distributions are the same, that is F(x)=G(x),
and this is to be tested against an alternative hypothesis H
1
which is
H : F(x)/=G(y); or
1
H : F(x)>G(y); or
1
H : F(x)<G(y),
1
using a two-tailed, upper-tailed or lower-tailed probability
respectively. The user selects the alternative hypothesis by
choosing the appropriate tail probability to be computed.
Note that when using this test to test for differences in the
distributions one is primarily detecting differences in the
location of the two distributions. That is to say, if we reject
the null hypothesis H in favour of the alternative hypothesis
0
H : F(x)<G(y) we have evidence to suggest that the location, of
1
the distribution defined by F(x), is less than the location, of
the distribution defined by G(y).
The Mann-Whitney U test differs from the Median test (see G08ACF)
in that the ranking of the individual scores within the pooled
sample is taken into account, rather than simply the position of
a score relative to the median of the pooled sample. It is
therefore a more powerful test if score differences are
meaningful.
The test procedure involves ranking the pooled sample, average
ranks being used for ties. Let r be the rank assigned to x ,
1i i
i=1,2,...,n and r the rank assigned to y , j=1,2,...,n . Then
1 2j j 2
the test statistic U is defined as follows;
n
1 n (n +1)
-- 1 1
U= > r - --------
-- 1i 2
i=1
U is also the number of times a score in the second sample
precedes a score in the first sample (where we only count a half
if a score in the second sample actually equals a score in the
first sample).
G08AHF returns:
(a) The test statistic U.
(b) The approximate Normal test statistic,
1
U-mean(U)+- -
2
z= -------------
______
\/Var(U)
where
n n
1 2
mean(U)= ----
2
and
n n (n +n +1) n n
1 2 1 2 1 2
Var(U)= ------------- - ----------------*TS
12 (n +n )(n +n -1)
1 2 1 2
where
(tau) (t )(t -1)(t +1)
-- j j j
TS= > ----------------
-- 12
j=1
(tau) is the number of groups of ties in the sample and t
j
is the number of ties in the jth group.
Note that if no ties are present the variance of U reduces
to n n (n +n +1)/12.
1 2 1 2
(c) An indicator as to whether ties were present in the pooled
sample or not.
(d) The tail probability, p, corresponding to U (adjusted to
allow the complement to be used in an upper 1-tailed or a
2-tailed test), depending on the choice of TAIL, i.e., the
choice of alternative hypothesis, H . The tail probability
1
returned is an approximation of p is based on an
approximate Normal statistic corrected for continuity
according to the tail specified. If n and n are not very
1 2
large an exact probability may be desired. For the
calculation of the exact probability see G08AJF (no ties in
the pooled sample) or G08AKF (ties in the pooled sample).
The value of p can be used to perform a significance test
on the null hypothesis H against the alternative
0
hypothesis H . Let (alpha) be the size of the significance
1
test (that is, (alpha) is the probability of rejecting H
0
when H is true). If p<(alpha) then the null hypothesis is
0
rejected. Typically (alpha) might be 0.05 or 0.01.
Parameters
g08ahf
Required Input Arguments:
x (:) real
y (:) real
Optional Input Arguments: <Default>
tail (1) string 't'
ifail integer -1
Output Arguments:
u real
unor real
p real
ties logical
ranks (:) real
ifail integer